Merge "Clean up postgres connection handling"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 19 Oct 2016 01:24:07 +0000 (01:24 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 19 Oct 2016 01:24:07 +0000 (01:24 +0000)
1  2 
includes/libs/rdbms/database/Database.php
includes/libs/rdbms/loadbalancer/LoadBalancer.php

@@@ -25,7 -25,6 +25,7 @@@
   */
  use Psr\Log\LoggerAwareInterface;
  use Psr\Log\LoggerInterface;
 +use Wikimedia\ScopedCallback;
  
  /**
   * Relational database abstraction object
@@@ -609,11 -608,6 +609,11 @@@ abstract class Database implements IDat
                return !!( $this->mFlags & $flag );
        }
  
 +      /**
 +       * @param string $name Class field name
 +       * @return mixed
 +       * @deprecated Since 1.28
 +       */
        public function getProperty( $name ) {
                return $this->$name;
        }
                if ( $this->htmlErrors !== false ) {
                        ini_set( 'html_errors', $this->htmlErrors );
                }
+               return $this->getLastPHPError();
+       }
+       /**
+        * @return string|bool Last PHP error for this DB (typically connection errors)
+        */
+       protected function getLastPHPError() {
                if ( $this->mPHPError ) {
                        $error = preg_replace( '!\[<a.*</a>\]!', '', $this->mPHPError );
                        $error = preg_replace( '!^.*?:\s?(.*)$!', '$1', $error );
  
                        return $error;
-               } else {
-                       return false;
                }
+               return false;
        }
  
        /**
@@@ -21,7 -21,6 +21,7 @@@
   * @ingroup Database
   */
  use Psr\Log\LoggerInterface;
 +use Wikimedia\ScopedCallback;
  
  /**
   * Database connection, tracking, load balancing, and transaction manager for a cluster
@@@ -553,7 -552,7 +553,7 @@@ class LoadBalancer implements ILoadBala
                if ( $i == self::DB_REPLICA ) {
                        $this->mLastError = 'Unknown error'; // reset error string
                        # Try the general server pool if $groups are unavailable.
-                       $i = in_array( false, $groups, true )
+                       $i = ( $groups === [ false ] )
                                ? false // don't bother with this if that is what was tried above
                                : $this->getReaderIndex( false, $domain );
                        # Couldn't find a working server in getReaderIndex()?